#include "c14_T1_winec.h"
#include<iostream>
using std::cin;
using std::cout;
using std::endl;

Wine::Wine() :_wineLabel("None"), _year(0), _wineInformation(arrayInt(), arrayInt()) 
{

}

Wine::Wine(const char * wineLabel, int year, const int *yearArray, const int *bottlesArray) 
	: _wineLabel(wineLabel), _year(year)
{
	arrayInt a(year);
	arrayInt b(year);
	if (yearArray==NULL||bottlesArray==NULL)
		_wineInformation = std::make_pair(a, b);
	else
	{
		for (int i = 0; i < year; i++)
		{
			a[i] = yearArray[i];
			b[i] = bottlesArray[i];
		}
		_wineInformation = std::make_pair(a, b);
	}
}

void Wine::SetBottles()
{
	cout << "Enter " << _wineLabel << " data for " << _year << " year(s): " << endl;
	arrayInt a(_year);
	arrayInt b(_year);
	for (int i = 0; i < _year; i++)
	{
		cout << "Enter year: ";
		cin >> a[i];
		cout << "Enter bottles for that year: ";
		cin >> b[i];
	}
	_wineInformation=std::make_pair(a, b);
}

void Wine::Show() const
{
	int i;
	int size = _year;
	cout << "Wine: " << _wineLabel << endl;
	cout << "\tYear\tBottles" << endl;
	for (i = 0; i < size; i++)
		cout << "\t" << _wineInformation.first[i] << "\t" << _wineInformation.second[i] << endl;
	cout << "Total bottles for " << _wineLabel
		<< ": " << Sum() << endl;
}


int Wine::Sum()const
{
	return _wineInformation.second.sum();
}
